home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
JCSM Shareware Collection 1993 November
/
JCSM Shareware Collection - 1993-11.iso
/
cl720
/
sst115j.lzh
/
IDEMO.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-07-16
|
6KB
|
150 lines
/* ------------------------------------------------------------------------ */
/* idemo.c */
/* demo on input entry fields */
/* ------------------------------------------------------------------------ */
#include <dos.h>
#include <stdio.h>
#include <string.h>
#include <mem.h>
#include <stdlib.h>
#include <conio.h>
#include "sstkey.h"
#include "sstwin.h"
/* ------------------------------------------------------------------------ */
/* function prototypes */
/* ------------------------------------------------------------------------ */
void main (void);
int endstroke (int c);
/* ------------------------------------------------------------------------ */
/* structures used for demo */
/* ------------------------------------------------------------------------ */
typedef struct _info {
int x; /* x coordinate of the input prompt */
int y; /* x coordinate of the input prompt */
int (*fvalid)(char *); /* field validation function */
void (*fhelp) (char *); /* field help function */
int fht; /* filed help type */
int ft; /* field type */
int fa; /* field entry conversion attribute */
char *name; /* fields name */
char *mask;
} RECORD;
#define RCOUNT 11
RECORD r[RCOUNT] = {
{ 1, 0, NULL, NULL, HELP_KEYED, FLD_ALNUM, FLD_LJUST,
"Alpha & Numeric :", "_______________________________" },
{ 1, 1, NULL, NULL, HELP_KEYED, FLD_ALPHA, FLD_LJUST,
"Alpha :", "_______________________________" },
{ 1, 2, NULL, NULL, HELP_KEYED, FLD_DIGIT, FLD_LJUST,
"Digit :", "_______________________________" },
{ 1, 3, NULL, NULL, HELP_KEYED, FLD_ASCII, FLD_LJUST,
"Ascii :", "_______________________________" },
{ 1, 4, NULL, NULL, HELP_KEYED, FLD_PRINT, FLD_LJUST,
"Printable :", "_______________________________" },
{ 1, 5, NULL, NULL, HELP_KEYED, FLD_XDIGIT, FLD_LJUST,
"HeX :", "__________" },
{ 1, 6, NULL, NULL, HELP_KEYED, FLD_CURR, FLD_ZFILL,
"Currency :", "$___.__" },
{ 1, 7, NULL, NULL, HELP_KEYED, FLD_ASCII, FLD_RJUST,
"Ascii R-Just :", "_______________________________" },
{ 1, 8, NULL, NULL, HELP_KEYED, FLD_ASCII, FLD_LJUST |
FLD_TOUPPER,
"Ascii to-upper :", "_______________________________" },
{ 1, 9, NULL, NULL, HELP_KEYED, FLD_ASCII, FLD_LJUST |
FLD_TOLOWER,
"Ascii to-lower :", "_______________________________" },
{ 1, 10, NULL, NULL, HELP_KEYED, FLD_ASCII, FLD_LJUST |
FLD_TOPROPER,
"Ascii to-proper :", "_______________________________" }
};
/* ------------------------------------------------------------------------ */
/* this structure is extremely inefficient but still ive used it for the */
/* sake of the demo */
/* ------------------------------------------------------------------------ */
char *drec[RCOUNT] = {
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
};
/* ------------------------------------------------------------------------ */
/* test for an ending keystroke */
/* this function is used to overide the default ending keystroke function */
/* ------------------------------------------------------------------------ */
int endstroke(int c)
{
switch (c) {
case '\r':
case '\n':
case '\t':
case ESC:
case F8:
case F9:
case F10:
case PGUP:
case PGDN:
case HOME:
case END:
case UP:
case DOWN:
return TRUE;
default:
return FALSE;
}
}
/* ------------------------------------------------------------------------ */
void main(void)
{
WINDOW *wnd;
FIELD *fld;
int c, ch = 0;
if ((wnd = Westablish(10, 5, 13, 54)) == NULL)
return;
Wsettitle(wnd, "[Input Field Demo]",JUST_C);
Wsetcolour(wnd, WIN_BORDER, LIGHTGRAY, WHITE, BRIGHT);
Wsetcolour(wnd, WIN_TITLE, LIGHTGRAY, BLUE, DIM);
Wsetcolour(wnd, WIN_FACE, LIGHTGRAY, BLACK, DIM);
Wsetcolour(wnd, WIN_ACCENT, GREEN, BLACK, DIM);
Wsetcolour(wnd, WIN_FLDFACE, LIGHTGRAY, RED, DIM);
Wshow(wnd);
Finittemplate(wnd);
for (c = 0 ; c < RCOUNT ; c++) {
Wprompt(wnd, r[c].x, r[c].y, r[c].name);
fld = Festablish(wnd, r[c].x+18, r[c].y, r[c].mask,
drec[c], r[c].ft,r[c].fa);
if (r[c].fvalid)
Fpostvalidate(fld, r[c].fvalid);
if (r[c].fhelp)
Fhelpfunc(fld, r[c].fhelp,r[c].fht);
}
Fendfunc(endstroke);
while ((ch != ESC) && (ch != F10))
ch = Fdataentry(wnd,0);
Wdelete(wnd);
}